package org.hardstone.service.impl;

import org.hardstone.dao.BaseDAO;
import org.hardstone.domain.BaseItemDomain;
import org.hardstone.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;

import java.io.Serializable;
import java.util.List;
import java.util.Optional;


public abstract class BaseServiceImpl<T extends BaseItemDomain<PK>,PK extends Serializable,DAO extends BaseDAO<T,PK>> implements BaseService<T,PK> {

    protected DAO dao;

    @Autowired
    public BaseServiceImpl(DAO dao) {
        this.dao = dao;
    }
    @Override
    public List<T> findAll(Example ex) {
        return dao.findAll(ex);
    }

    @Override
    public Optional<T> findById(Serializable var1) {
        return dao.findById((PK)(var1));
    }

    @Override
    public boolean existsById(Serializable var1) {
        return dao.existsById((PK)(var1));
    }

    @Override
    public <S extends T> S save(S var1) {
        return dao.save(var1);
    }

    @Override
    public Iterable<T> findAll() {
        return dao.findAll();
    }

    @Override
    public Iterable<T> findAllById(Iterable<PK> var1) {
        return dao.findAllById(var1);
    }

    @Override
    public PK count() {
        return dao.count();
    }

    @Override
    public void delete(T var1) {
        dao.delete(var1);
    }

    @Override
    public void deleteById(Serializable var1) {
        dao.deleteById((PK)(var1));
    }

    @Override
    public void deleteAll(Iterable var1) {
        dao.deleteAll(var1);
    }

    @Override
    public void deleteAll() {
        dao.deleteAll();
    }

    @Override
    public <S extends T> Iterable<S> saveAll(Iterable<S> var1) {
        return dao.saveAll(var1);
    }

}
